<?php


namespace App\Transformers\Product;


use App\Models\ProductRelation;
use League\Fractal\TransformerAbstract;

class ProductRelationTransformer extends TransformerAbstract
{

    public function transform(ProductRelation $data)
    {
        return [
            'id' => $data->id,
            'product_id' => $data->product_id ?? '',
            'user_id' => $data->user_id ?? '',
            'type' => $data->type ?? '',
            'type_text' => $data->categoryTypeEnum[$data->type] ?? '',
            'category' => $data->category ?? '',
            'created_at' => $data->created_at ? $data->created_at->format("Y-m-d H:i:s") : '',
            'updated_at' => $data->updated_at ? $data->updated_at->format("Y-m-d H:i:s") : '',
        ];
    }



}
